﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _25参数返回值
{
    class Program
    {
        static void Main(string[] args)
        {
            //int num;
            //int res = Sum(out num);
            //Console.WriteLine("num={0},res={1}", num, res);
            //Console.ReadKey();



            //练习一out参数
            //Console.WriteLine("请输入账号：");
            //string a = Console.ReadLine();
            //Console.WriteLine("请输入密码");
            //string b = Console.ReadLine();
            //string j;
            //bool l = Sen(a, b, out j);
            //Console.WriteLine("登录结果：{0}", l);
            //Console.WriteLine("登陆结果：{0}", j);
            //Console.ReadKey();


            //ref参数
            //int n1 = 10;
            //int n2 = 20;
            //Str(ref n1,ref n2);
            //Console.WriteLine(n1);
            //Console.WriteLine(n2);
            //Console.ReadLine();


            //params可变参数
            Test("张三", 99, 98, 77);
            Console.ReadKey();
        }
        /*
        static int Sum(out int a)
        {
            a = 10;
            a = a + 1;

            return 200;
        }*/


        //练习一out参数
        /// <summary>
        /// 判断登录是否成功
        /// </summary>
        /// <param name="a">用户名</param>
        /// <param name="b">密码</param>
        /// <param name="j">多余返回的登录信息</param>
        /// <returns>返回登录结果</returns>
        //public static bool Sen(string a, string b, out string j)
        //{
        //    if (a == "asdf" && b == "123")
        //    {
        //        j = "登录成功";
        //        return true;
        //    }
        //    else if (a == "asdf")
        //    {
        //        j = "密码错误";
        //        return false;
        //    }
        //    else if (b == "123")
        //    {
        //        j = "账号错误";
        //        return false;
        //    }
        //    else
        //    {
        //        j = "未知错误";
        //        return false;
        //    }
        //}


        //ref参数
        //public static void Str(ref int n1, ref int n2)
        //{
        //    int temp = n1;
        //    n1 = n2;
        //    n2 = temp;
        //}


        //params可变参数
        public static void Test(string name, params int[] sex)
        {
            int sum = 0;
            for (int i = 0; i < sex.Length; i++)
            {
                sum += sex[i];
            }
            Console.WriteLine("{0}这次的考试总成绩是{1}",name,sum);
        }
    }
}
